import Vue from 'vue'
import VueRouter from 'vue-router'
// // 导入1级路由
// import layout from '@/views/layout'
// import play from '@/views/play'
// // 导入2级路由
// import home from '@/views/home'
// import search from '@/views/search'

const layout = () => import('@/views/layout')
const play = () => import('@/views/play')
const home = () => import('@/views/home')
const search = () => import('@/views/search')
Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/layout/home' },
  {
    name: 'layout',
    path: '/layout',
    component: layout,
    children: [
      {
        name: 'home',
        path: 'home',
        component: home,
        // 给路由打标记 -- 换句话说：可以把一些存到路由上
        meta: {
          title: '首页'
        }
      },
      {
        name: 'search',
        path: 'search',
        component: search,
        meta: {
          title: '搜索'
        }
      }
    ]
  },
  { name: 'play', path: '/play', component: play }
]

const router = new VueRouter({
  routes
})

export default router
